//
//  MMProgressHUD+HUDShowExtral.m
//  VXiao
//
//  Created by YiJianJun on 14-2-22.
//  Copyright (c) 2014年 hc. All rights reserved.
//

#import "MMProgressHUD+HUDShowExtral.h"
#import "NSObject+ObjectExtral.h"

@implementation MMProgressHUD (HUDShowExtral)

///简单的弹出提示
+ (void)showTips:(NSString *)tips titile:(NSString *)titile{
    if([tips isVaildValue]){
        [self showWithTitle:titile status:tips];
        [self dismissAfterTime:1.0f];
    }
}

+ (void)showSuccessWithTips:(NSString *)tips{
    if([tips isVaildValue]){
        [[[self sharedHUD] hud] setCompletionState:MMProgressHUDCompletionStateSuccess];
        [self showWithTitle:nil status:tips];
        [self dismissAfterTime:1.0f];
    }
}

+ (void)showInformationWithTips:(NSString *)tips{
    if([tips isVaildValue]){
        [[[self sharedHUD] hud]setCompletionState:MMProgressHUDCompletionStateError];
        [self showWithTitle:nil status:tips];
        [self dismissAfterTime:1.0f];
    }
}

+ (void)showMessage:(NSString *)message{
    if([message isVaildValue]){
        [self showTips:message titile:nil];
    }
}

+ (void)showHoldOnMessage{
    [MMProgressHUD showMessage:@"请稍后..."];
}

+ (void)dismissAfterTime:(NSTimeInterval)interval{
    double delayInSeconds = interval;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [self dismiss];
    });
}
@end
